
#include "core.h"
#include "hd.h"

//#include <stdint.h>


volatile uint8_t task_delay[]={task_delay0,task_delay1};//,task_delay2};//,task_delay2,task_delay3}; // 0 adc 1 key 2 statu 3 display
const uint8_t task_period[]={task_delay0,task_delay1};//,task_delay2};//,task_delay2,task_delay3};
void core(void)
{
	uint8_t i_tim0=0x00;
	for(i_tim0=0;i_tim0<max_task;i_tim0++)
	{
		if(task_delay[i_tim0])
		{
		    task_delay[i_tim0]--;
		}
	}
}

void run(void (* ptask)(void))
{
	(* ptask)();
}

void (* task[])(void)={rf,display};//{rf,display}//,AM2301_Data};//{g_adc,SearchMSGMAP,display,current};

void task_update(void)
{
    uint8_t i_task=0;
    uint8_t i_task1=0;
    for(i_task=0;i_task<max_task;i_task++)
    {
        if(task_delay[i_task]==0)
        {
            for(;i_task1<i_task;i_task1++)
            {
                if(task_delay[i_task1]==0)
                {
                    i_task=i_task1;
                }
            }
            run(task[i_task]);
            task_delay[i_task]=task_period[i_task];
//			wdt_reset();
  //          break;
        }
    }
}
